
import { IGlobalData } from "./bcat/i-global-data"
import {ITotpInfo, createTotp,  createTotpTest} from "./biz/totp-info"


import { TotpStorage, test as testTotp  } from "./biz/storage/totp-storage"
import { VariableStorage} from "./bcat/storage/variable-storage"


export class GlobalData implements IGlobalData {

  totpInfo: ITotpInfo
  vsIsTermAgree: VariableStorage;

  constructor() {
    //this.url = 'http://175.24.184.170:8000';
    //this.userName = "helloworld"

    //this.totpInfo = createTotpTest();

    //load from local storage
    let totp = TotpStorage.fromDefault().load();
    //console.log("load from storage:", totp);
    if(totp === undefined){
      totp = createTotp();
    }
    this.totpInfo = totp;


    this.vsIsTermAgree = VariableStorage.loadFromDefault("KEY_IS_TERM_AGREE");
    console.log("load isTermAgree from default storage:", this.vsIsTermAgree.get());
  }
}

